How create a time object of VBS in perl?

How create a time object of VBS in perl?

am 19.09.2010 08:39:41 von Xiao Yafeng

--===============0553732286==
Content-Type: multipart/alternative; boundary=0016363ba5dead86b90490971043

--0016363ba5dead86b90490971043
Content-Type: text/plain; charset=ISO-8859-1

Hi,
Could you tell me how create a time object of VBS in perl? Below
statement define a starting time and pass it to the getdata function to get
data in VBS:

start_time = DateSerial( 2003, 01, 31) + TimeSerial( 6, 0, 0)
data_array = lpd.getdata(id, start_time)

But I don't know how to translate it into perl.
Since I intend to rewrite all vbs scripts, it will be a big problem!
How?
Any replies are really appreciated!
TIA.

--0016363ba5dead86b90490971043
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi,
   Could you tell me how create a time object o=
f VBS in perl? Below statement define a starting time and pass it to the ge=
tdata function to get data in VBS:

start_time =3D =
DateSerial( 2003, 01, 31) + TimeSerial( 6, 0, 0)


data_array =3D lpd.getdata(id, start_time)

<=
div>But I don't know how to translate it into perl.=A0
Since =
I intend to rewrite all vbs scripts, it will be a big problem!
Ho=
w?


Any replies are really appreciated!
TIA.


--0016363ba5dead86b90490971043--

--===============0553732286==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============0553732286==--

Re: How create a time object of VBS in perl?

am 19.09.2010 11:31:53 von Bill Luebkert

On 9/18/2010 11:39 PM, Xiao Yafeng wrote:
>
> start_time = DateSerial( 2003, 01, 31) + TimeSerial( 6, 0, 0)
> data_array = lpd.getdata(id, start_time)

I think VB uses a different time format than most Windoze system times.

See if these help:
http://msdn.microsoft.com/en-us/library/3eaydw6e%28v=VS.80%2 9.aspx
http://msdn.microsoft.com/en-us/library/bbx05d0c%28VS.80%29. aspx
http://msdn.microsoft.com/en-us/library/ws25fd2z%28VS.80%29. aspx
http://msdn.microsoft.com/en-us/library/system.datetime%28v= VS.80%29.aspx

Time conversion:
http://msdn.microsoft.com/en-us/library/ms973825.aspx

I've converted various Windoze times (file time, system time) back
and forth to the standard epoch time we/UNIX use, but this time
(apparently DateTime format) appears to be different from file time
or system time.

# Epoch: seconds since January 1, 1970 (32 bits)
# FileTime: clunks (100-ns intervals) since January 1, 1601 (64 bits)
# System time array: Yr, Mon, DOW, Day, Hr, Min, Sec, Msec

------------------------------------------------------------ -----------------

From Date Time Structure writeup:

The DateTime value type represents dates and times with values ranging from
12:00:00 midnight, January 1, 0001 Anno Domini (Common Era) through 11:59:59
P.M., December 31, 9999 A.D. (C.E.)

Time values are measured in 100-nanosecond units called ticks, and a particular
date is the number of ticks since 12:00 midnight, January 1, 0001 A.D. (C.E.)
in the GregorianCalendar calendar. For example, a ticks value of
31241376000000000L represents the date, Friday, January 01, 0100 12:00:00
midnight. A DateTime value is always expressed in the context of an explicit
or default calendar.

------------------------------------------------------------ -----------------

You could convert any time to the system time array format and add a field
for clunks or fractional msecs after the msec and write conversion routines
to convert back and forth to whatever time format you like. Personally,
I find epoch time is the easiest to use and works for most situations since
it's a simple integer of seconds since 1970 and you can use a second integer
for fractional seconds/msecs.
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

RE: How create a time object of VBS in perl?

am 19.09.2010 13:48:19 von Michael.Ludwig

> Could you tell me how create a time object of VBS in perl? Below
> statement define a starting time and pass it to the getdata function
> to get data in VBS:
>
> start_time = DateSerial( 2003, 01, 31) + TimeSerial( 6, 0, 0)
> data_array = lpd.getdata(id, start_time)
>
> But I don't know how to translate it into perl.
> Since I intend to rewrite all vbs scripts, it will be a big problem!

Using Windows Script Files (.wsf)
http://msdn.microsoft.com/en-us/library/15x4407c%28VS.85%29. aspx

WSF might be helpful to you. It allows you to have several engines
work jointly. You might be able to keep the parts in VBS that are not
practical to port to Perl. It is XML, so you can use Unicode in your
script.

--
Michael Ludwig
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: How create a time object of VBS in perl?

am 19.09.2010 16:54:09 von John Mason Jr

On 9/19/2010 7:48 AM, Ludwig, Michael wrote:
>> Could you tell me how create a time object of VBS in perl? Below
>> statement define a starting time and pass it to the getdata function
>> to get data in VBS:
>>
>> start_time = DateSerial( 2003, 01, 31) + TimeSerial( 6, 0, 0)
>> data_array = lpd.getdata(id, start_time)
>>
>> But I don't know how to translate it into perl.
>> Since I intend to rewrite all vbs scripts, it will be a big problem!
> Using Windows Script Files (.wsf)
> http://msdn.microsoft.com/en-us/library/15x4407c%28VS.85%29. aspx
>
> WSF might be helpful to you. It allows you to have several engines
> work jointly. You might be able to keep the parts in VBS that are not
> practical to port to Perl. It is XML, so you can use Unicode in your
> script.
>

If you are doing a bunch of conversions then you might want to look at
the Perl Dev Kit as it has a vbscript to perl converter

John
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Re: How create a time object of VBS in perl?

am 19.09.2010 17:22:59 von Xiao Yafeng

--===============2140351297==
Content-Type: multipart/alternative; boundary=00163683217426f8e104909e60ca

--00163683217426f8e104909e60ca
Content-Type: text/plain; charset=ISO-8859-1

I've used vbconverter to translate now function into perl:

package VBS;
use strict;

use Win32::OLE::NLS qw(:TIME
:DATE
GetLocaleInfo GetUserDefaultLCID
LOCALE_SMONTHNAME1 LOCALE_SABBREVMONTHNAME1
LOCALE_SDAYNAME1 LOCALE_SABBREVDAYNAME1
LOCALE_IFIRSTDAYOFWEEK
LOCALE_SDATE LOCALE_IDATE
LOCALE_SGROUPING
);
use Win32::OLE::Variant;

use constant EPOCH => 25569;
use constant SEC_PER_DAY => 86400;

our $lcid;
BEGIN {
$lcid = GetUserDefaultLCID();
Win32::OLE->Option(LCID => $lcid);
}

# Return the local time in seconds since the epoch.
sub _localtime_in_sec {
require Time::Local;
return 2.0 * CORE::time() - Time::Local::timelocal(gmtime);
}

# Extract specific information out of a date.
sub _extract_from_date {
my($date,$method,$format) = @_;
return unless $date;
unless (UNIVERSAL::isa($date, "Win32::OLE::Variant")) {
$date = Variant(VT_DATE, $date);
}
return $date->$method($format, $lcid);
}

# Returns the current date and time according to the setting of your
# computer's system date and time.
sub Now {
return Variant(VT_DATE, EPOCH + _localtime_in_sec()/SEC_PER_DAY);
}

As above code, VB's time format is just dates wrapped by VT_DATE. Is it
right?
And, What is lcid? What is the usage of redundant package ( Win32::OLE::NLS
) and function ( _extract_from_date) ?



On Sun, Sep 19, 2010 at 10:54 PM, John Mason Jr wrote:

> On 9/19/2010 7:48 AM, Ludwig, Michael wrote:
> >> Could you tell me how create a time object of VBS in perl? Below
> >> statement define a starting time and pass it to the getdata function
> >> to get data in VBS:
> >>
> >> start_time = DateSerial( 2003, 01, 31) + TimeSerial( 6, 0, 0)
> >> data_array = lpd.getdata(id, start_time)
> >>
> >> But I don't know how to translate it into perl.
> >> Since I intend to rewrite all vbs scripts, it will be a big problem!
> > Using Windows Script Files (.wsf)
> > http://msdn.microsoft.com/en-us/library/15x4407c%28VS.85%29. aspx
> >
> > WSF might be helpful to you. It allows you to have several engines
> > work jointly. You might be able to keep the parts in VBS that are not
> > practical to port to Perl. It is XML, so you can use Unicode in your
> > script.
> >
>
> If you are doing a bunch of conversions then you might want to look at
> the Perl Dev Kit as it has a vbscript to perl converter
>
> John
> _______________________________________________
> ActivePerl mailing list
> ActivePerl@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>

--00163683217426f8e104909e60ca
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

I've used vbconverter to translate now function into perl:


v>
package VBS;
use strict;

use=
Win32::OLE::NLS qw(:TIME
"white-space:pre"> =A0 =A0 =A0 :DATE


=A0=
=A0 =A0 GetLocaleInfo GetUserDefaultLCID
   =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 LOCALE_SMONTHNAME1 LOCALE_SABBREVMONTHNAME1
iv>   =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 LOCALE_SDAYNAME1 LOCALE_S=
ABBREVDAYNAME1


=A0=
=A0 =A0 LOCALE_IFIRSTDAYOFWEEK
yle=3D"white-space:pre"> =A0 =A0 =A0 LOCALE_SDATE LOCALE_IDATE v>
=
=A0 =A0 =A0 LOCALE_SGROUPING


=A0=
=A0 =A0 );
use Win32::OLE::Variant;

use=
constant EPOCH =A0 =A0 =A0 =3D> 25569;
use constant SEC_PER_D=
AY =3D> 86400;



our $lcid;
BEGIN {
   =A0$lcid =
=3D GetUserDefaultLCID();
   =A0Win32::OLE->Option(LCID =
=3D> $lcid);
}

# Return the local tim=
e in seconds since the epoch.


sub _localtime_in_sec {
   =A0require Time::Local;
=
   =A0return 2.0 * CORE::time() - Time::Local::timelocal(gmtime);<=
/div>
}

# Extract specific information out of =
a date.


sub _extract_from_date {
   =A0my($date,$method,$format)=
=3D @_;
   =A0return unless $date;
   =A0unles=
s (UNIVERSAL::isa($date, "Win32::OLE::Variant")) {
=A0=
=A0 =A0 =A0 =A0$date =3D Variant(VT_DATE, $date);


   =A0}
   =A0return $date->$method($format, $lci=
d);
}

# Returns the current date and tim=
e according to the setting of your
# computer's system date a=
nd time.


sub Now {
   =A0return Variant(VT_DATE, EPOCH + _localti=
me_in_sec()/SEC_PER_DAY);
}

As abo=
ve code, VB's time format is just dates wrapped by VT_DATE. Is it right=
?


And, What is lcid? What is the usage of redundant package (=A0Win32::O=
LE::NLS ) and function (=A0_extract_from_date) ?
ontent-type" content=3D"text/html; charset=3Dutf-8"> tent-type" content=3D"text/html; charset=3Dutf-8">


=A0


On Sun, Sep 19,=
2010 at 10:54 PM, John Mason Jr < hn.mason.jr@cox.net" target=3D"_blank">john.mason.jr@cox.net>=
wrote:


x #ccc solid;padding-left:1ex">
=A0On 9/19/2010 7:48 AM, Ludwig, Michael wrote:

>> =A0 =A0 Could you tell me how create a time object of VBS in perl?=
Below

>> statement define a starting time and pass it to the getdata functi=
on

>> to get data in VBS:

>>

>> start_time =3D DateSerial( 2003, 01, 31) + TimeSerial( 6, 0, 0) >
>> data_array =3D lpd.getdata(id, start_time)

>>

>> But I don't know how to translate it into perl.

>> Since I intend to rewrite all vbs scripts, it will be a big proble=
m!

> Using Windows Script Files (.wsf)

> ..aspx" target=3D"_blank">http://msdn.microsoft.com/en-us/library/15 x4407c%2=
8VS.85%29.aspx


>

> WSF might be helpful to you. It allows you to have several engines

> work jointly. You might be able to keep the parts in VBS that are not<=
br>
> practical to port to Perl. It is XML, so you can use Unicode in your r>
> script.

>



If you are doing a bunch of conversions then you might want to look a=
t

the Perl Dev Kit as it has a vbscript to perl converter



John

_______________________________________________=


ActivePerl mailing list

Ac=
tivePerl@listserv.ActiveState.com


To unsubscribe: target=3D"_blank">http://listserv.ActiveState.com/mailman/my subs





--00163683217426f8e104909e60ca--

--===============2140351297==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
--===============2140351297==--